package com.dcivision.dms.web;

import java.sql.Connection;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.dcivision.framework.GlobalConstant;
import com.dcivision.framework.SessionContainer;
import com.dcivision.framework.TextUtility;
import com.dcivision.framework.Utility;
import com.dcivision.framework.web.AbstractMaintAction;

public class MaintDmsPopComplexAction extends AbstractMaintAction {
  public static final String REVISION = "$Revision: 1.6 $";

  public String getFunctionCode() {
	return null;
  }

  public String getMajorDAOClassName() {
	return null;
  }
  
  public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response)throws ServletException {

    MaintDmsPopComplexForm actionForm = (MaintDmsPopComplexForm) form;
    SessionContainer sessionContainer = this.getSessionContainer(request);
    Connection conn = this.getConnection(request);
    
    //this request parameter come from SelectUserTag
    String userID = request.getParameter("userID");
    String groupID = request.getParameter("groupID");
    String roleID = request.getParameter("roleID");
    String index = request.getParameter("index");
    String passValue = request.getParameter("passValue");
    String ID = request.getParameter("ID");
    
    if (!Utility.isEmpty(userID)){
      String[] userRecords = TextUtility.splitString(userID, ",");
      actionForm.setUserRecords(userRecords);
    }
    if (!Utility.isEmpty(groupID)){
      String[] userGroups = TextUtility.splitString(groupID, ",");
      actionForm.setUserGroups(userGroups);
    }
    if (!Utility.isEmpty(roleID)){
      String[] userRoles = TextUtility.splitString(roleID, ",");
      actionForm.setUserRoles(userRoles);
    }
    
    request.setAttribute("index",index);
    request.setAttribute("passValue",passValue);
    request.setAttribute("ID", ID);
    
    return mapping.findForward(GlobalConstant.NAV_MODE_EDIT); 
    
  }
  
  
}
